import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: GuoZheng
 * Date: 13-9-30
 * Time: 上午10:04
 * To change this template use File | Settings | File Templates.
 */
public class Main {

    public static void main(String[] args) throws IOException {
        //原始文件名称
        String originalFileName = "D://sql.ini";
        //需要对比的文件夹
        String destDirName = "D://dest/";
        //原始文件
        File file = new File(originalFileName);
        //需要对比的文件夹
        File destDir = new File(destDirName);
        //以下初始对比数据
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        String line = bufferedReader.readLine();
        List<String> lst = new ArrayList<String>();
        while (line != null) {

            if (line.startsWith("master=")) {
                lst.add(line);
            }
            line = bufferedReader.readLine();
        }

        if (destDir.isDirectory()) {
            String[] names = destDir.list();
            File dest;
            for (String name : names) {
                dest = new File(destDirName + name);
                BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(dest)));
                String l = reader.readLine();
                while (l != null) {
                    if (l.startsWith("master=")) {
                        if (lst.contains(l)) {
                            System.out.println(name);
                            reader.close();
                            break;
                        }
                    }
                    l = reader.readLine();
                }
            }
        } else {
            System.out.println("目标不是文件夹");
            return;
        }


    }
}

